<?php
/* * * del.php * * */


if (isset($_GET["delzid"]) && isset($_POST["who"]))
{
  deleteZ($_GET["delzid"], $_POST["who"]);
}

if (isset($_GET["delpzid"]) && isset($_POST["who"]))
{
  deletePZ($_GET["delpzid"], $_POST["who"]);
}

if (isset($_GET["delkid"]) && isset($_POST["who"]))
{
  deleteK($_GET["delkid"], $_POST["who"]);
}

if (isset($_GET["delallk"]) && isset($_POST["who"]))
{
  $select = "select id from klient";
  $result = GetDbResult($select);

  while ($pole = GetDbFArray($result))
  {
    deleteK($pole["id"], $_POST["who"]);
  }
}

if (isset($_GET["delallz"]) && isset($_POST["who"]))
{
  $select = "select id from zakazka";
  $result = GetDbResult($select);

  while ($pole = GetDbFArray($result))
  {
    deleteZ($pole["id"], $_POST["who"]);
  }
}

?>
<form name="fadmin" id="fadmin" method="post">
zakazky&nbsp;&nbsp;
<?php
echo "<input type=\"submit\" name=\"del\" value=\"delete all\" onclick=\"confirmChanges('who', 'fadmin', 'index.php?type=admin&det=del&delallz=')\" />\n";
?>
<hr>
<?php


$select = "select *, cislo_objednavky as cz from zakazka";

$result = GetDbResult($select);

while ($pole = GetDbFArray($result))
{
  echo $pole["cz"]."&nbsp;<input type=\"submit\" name=\"del\" value=\"delete\" onclick=\"confirmChanges('who', 'fadmin', 'index.php?type=admin&det=del&delzid=".$pole["id"]."')\" /><br>\n";
  
  $select = "select * from podzakazka where zakazka_id = ".$pole["id"];
  $respz = GetDbResult($select);
  while ($pz = GetDbFArray($respz))
  {
    echo "&nbsp;&nbsp;&nbsp;&nbsp;"
      .$pz["cislo_objednavky"]."&nbsp;<input type=\"submit\" name=\"del\" value=\"delete\" onclick=\"confirmChanges('who', 'fadmin', 'index.php?type=admin&det=del&delpzid=".$pz["id"]."')\" /><br>\n";
  }

}

?>
<hr>
klienti&nbsp;&nbsp;
<?php
echo "<input type=\"submit\" name=\"del\" value=\"delete all\" onclick=\"confirmChanges('who', 'fadmin', 'index.php?type=admin&det=del&delallk=')\" />\n";
?>
<hr>
<table>
<?php
$select = "select id, obchodni_jmeno from klient";
$result = GetDbResult($select);

while ($pole = GetDbFArray($result))
{
  echo "<tr>\n";
  echo "<td><a href=\"index.php?type=base&det=pridat_klienta&editk=".$pole["id"]."\">".$pole["obchodni_jmeno"]."</td>";
  echo "<td><input type=\"submit\" name=\"del\" value=\"delete\" onclick=\"confirmChanges('who', 'fadmin', 'index.php?type=admin&det=del&delkid=".$pole["id"]."')\" /></td>\n";
  echo "</tr>\n";
}
?>
</table>

<input type="hidden" name="who" id="who" value="" />
</form>
